package me.minecraft.plugin.cobblemonclear.util;

import com.cobblemon.mod.common.api.pokemon.PokemonProperties;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.pokemon.Pokemon;
import lg.minecraft.plugin.cobblemoncore.util.BukkitNmsConverter;
import lg.minecraft.plugin.cobblemoncore.util.CobblemonType;
import lg.minecraft.plugin.entityclear.component.EntityFilter;
import lg.minecraft.plugin.entityclear.component.EntityRemover;
import lg.minecraft.plugin.entityclear.parser.ParserContext;
import org.bukkit.configuration.ConfigurationSection;

import java.util.List;

/**
 * @author langle__
 * @version 1.0
 */
public class ComponentUtil {

    public static EntityFilter createCobblemonEntityFilter(ParserContext context) {
        ConfigurationSection config = context.getConfig();
        List<String> list = config == null ? List.of() : config.getStringList("list");
        PokemonFilter pokemonFilter = PokemonFilter.create(list);
        return entity -> {
            if (entity.getType() != CobblemonType.COBBLEMON_POKEMON_TYPE) return false;
            PokemonEntity pokemonEntity = BukkitNmsConverter.toPokemonEntity(entity);
            if (pokemonEntity.isBattling()) return false;
            Pokemon pokemon = pokemonEntity.getPokemon();
            if (pokemon.isWild()) return false;
            return pokemonFilter.matches(pokemon);
        };
    }

    public static EntityRemover createCobblemonEntityRemover(ParserContext context) {
        return null;
    }

}
